﻿Public Class frmInsertarEstrella

    Private Sub frmInsertarEstrella_Activated(sender As Object, e As EventArgs) Handles Me.Activated
        ModuloGeneral.Centrar(Me.Panel1)

    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim Validor As New ValidadorDeFormularios(Me, ErrorProvider1)
        Dim FormularioValido As Boolean = Validor.ValidarFormulario()

        If FormularioValido = False Then
            Return
        End If

        Dim strNombre As String = Me.txtString.Text
        Dim numMasa As Decimal = Convert.ToDecimal(Me.txtDecimal1.Text)
        Dim numTemp As Decimal = Convert.ToDecimal(Me.txtDecimal2.Text)
        Dim numDDia As TimeSpan = New TimeSpan(Convert.ToDecimal(Me.txtDate.Text) * 24, 0, 0)
        Dim numEdad As Decimal = Convert.ToDecimal(Me.txtDecimal3.Text)
        Dim strComposicion As String = Me.txtString2.Text
        Dim numIntensidad As Decimal = Convert.ToDecimal(Me.txtDecimal4.Text)
        Dim numTamaño As Decimal = Convert.ToDecimal(Me.txtDecimal5.Text)


        If objGestor.insertarEstrella(strNombre, numMasa, numTemp, numDDia, numEdad, strComposicion, numIntensidad, numTamaño) Then
            MsgBox("La Estrella fue Registrada correctamente.")
            Me.txtString.Text = ""
            Me.txtDecimal1.Text = ""
            Me.txtDecimal2.Text = ""
            Me.txtDate.Text = ""
            Me.txtDecimal3.Text = ""
            Me.txtString2.Text = ""
            Me.txtDecimal4.Text = ""
            Me.txtDecimal5.Text = ""
            Me.txtString.Focus()
        Else
            MsgBox("La EStrella No fue Registrada, por favor verifique...")
        End If

    End Sub

    'Private Sub txtNombre_Validating(ByVal Sender As Object, _
    ' ByVal e As System.ComponentModel.CancelEventArgs) Handles _
    'txtString.Validating

    ' If Trim(txtString.Text) = "" Then
    ' MsgBox("Por favor ingrese su nombre")
    ' ErrorProvider1.SetError(txtString, "Not a numeric value.")
    ' Else
    ' Clear the error.
    'ErrorProvider1.SetError(txtString, "")
    'End If
    ' End Sub

    ' Private Sub txtMasa_Validating(ByVal Sender As Object, _
    'ByVal e As System.ComponentModel.CancelEventArgs) Handles _
    'txtDecimal1.Validating

    'If Trim(txtDecimal1.Text) = "" Or _
    'Not IsNumeric(txtDecimal1.Text) Then
    'MsgBox("Por favor ingrese correctamente la masa")
    'ErrorProvider1.SetError(txtDecimal1, "Not a numeric value.")
    'Else
    ' Clear the error.
    'ErrorProvider1.SetError(txtDecimal1, "")
    'End If
    'End Sub

    Private Sub frmInsertarEstrella_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class